package offer;

import common.ListNode;

public class Offer_22 {

    public ListNode getKthFromEnd(ListNode head, int k) {
        ListNode tail = head;
//        int headIndex = 0;
        int tailIndex = 0;
        while (tail.next != null) {
            tail = tail.next;
            tailIndex++;
            if (tailIndex > k) {
                head = head.next;
//                headIndex++;
            }
        }
        return head;
    }
}
